// 加载状态的类库
import type { IStateCreateOption } from '../../lib/types/type'

export type IStateAll = {
  name: string;
  age: number;
  get getName(): string;
  get getAge(): number;
  addAge(n: number): void;
  addAge2(n: number): void;
}

// 仅 state + 对象
export const stateAll: IStateCreateOption = {
  state: () => {
    return {
      name: '基础设置',
      age: 20
    }
  },
  getters: {
    getName() {
      return this.name + ' + 普通函数'
    },
    getAge: (state: any) => {
      return state.age + ' + 箭头函数'
    }

  },
  actions: {
    addAge(n = 1) {
      this.age += n

    },
    addAge2: (state: any, n = 1 ) => {
      state.age += 10 * n
    }

  },
  options: {
    isLog: false
  }
}